#include <iostream>
#include <vector>
#include <string>
#include <stdbool.h>
using namespace std;

class Solution
{
public:
    bool checkPartitioning(string s)
    {
        int n = s.size();
        vector<vector<bool>> dp(n, vector<bool>(n));

        for (int i = n - 1; i > -1; i--)
            for (int j = i; j < n; j++)
                if (s[i] == s[j])
                    dp[i][j] = i + 1 < j ? dp[i + 1][j - 1] : true;

        for (int i = 1; i <= n - 2; i++)
            for (int j = i; j <= n - 2; j++)
                if (dp[0][i - 1] && dp[i][j] && dp[j + 1][n - 1]) return true;
        return false;
    }
};

void Test01()
{

}

int main()
{
    Test01();
    return 0;
}